#include <stdio.h>
#include <SWI-Prolog.h>


int main(int argc, char **argv)
{
  char *plav[2];
  char *resultado;
  term_t terms[3];
  plav[0] = argv[0];
  plav[1] = NULL;
   
  if ( !PL_initialise(1, plav) )
    PL_halt(1);




  { predicate_t pred = PL_predicate("distHam", 3, "tp2");
    terms[0] = PL_new_term();
    terms[1] = PL_new_term();
    terms[2] = PL_new_term();

    PL_unify_atomic(terms[0], PL_new_atom("[0]"));
    PL_unify_atomic(terms[1], PL_new_atom("[0]"));
    PL_unify_atomic(terms[2], PL_new_atom("N"));

    int rval;

    rval = PL_call_predicate(NULL, PL_Q_NORMAL, pred, terms);

	  printf("\nSalida :\n\n");
	  PL_get_chars(terms+1, &resultado, CVT_WRITE);
	  printf("%s\n\n",resultado);
    	  PL_halt(rval ? 0 : 1);
  }
  return 0;
}
